/**
 * 
 */
package daos;

import model.StudentProfile;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Transactional;


public class StudentProfileDAOImpl implements StudentProfileDAO {
	private SessionFactory sessionFactory;
	
	@Transactional
	public void save(StudentProfile student) {
		Session session = this.sessionFactory.getCurrentSession();
		session.saveOrUpdate(student);
	}

	@Transactional
	public List<StudentProfile> findStudents() {
		Session session = this.sessionFactory.getCurrentSession();
		Query query = session.createQuery("from StudentProfile");
		return query.list();
	}
	@Transactional
	public void delete(StudentProfile student) {
		Session session = this.sessionFactory.getCurrentSession();
		session.delete(student);
	}
	@Transactional
	public StudentProfile findStudentById(int id) {
		Session session = this.sessionFactory.getCurrentSession();
		return (StudentProfile)session.get(StudentProfile.class, id);
	}
	/*
	@Transactional
	public StudentClass findStudentClass(StudentProfile studentProfile){
		Session session = this.sessionFactory.getCurrentSession();
		Query query = session.createQuery("from StudentProfile p where studentClass:=studentClass");
	}*/
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	
}